using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UI_WeaponSelect : MonoBehaviour
{
    [SerializeField] private UI_WepaonSelectSlot[] _weaponSelectSlots;
    private UI uI;

    private void Awake()
    {
        uI = GetComponentInParent<UI>();
    }

    public void SetupWeaponSelectUI(List<WeaponScrollDataSO> weaponItemDataList)
    {
        Debug.Log(weaponItemDataList.Count);
        for (int i = 0; i < _weaponSelectSlots.Length; i++)
        {
            if (i < weaponItemDataList.Count)
                _weaponSelectSlots[i].SetupWeaponSelectSlot(weaponItemDataList[i]);
        }
    }
    
    public void ClickSelectButton()
    {
        for (int i = 0; i < _weaponSelectSlots.Length; i++)
        {
            UI_WepaonSelectSlot wepaonSelectSlot = _weaponSelectSlots[i];
            if (wepaonSelectSlot.IsSelect())
                EventCenter.TriggerEvent(EventName.UI_AddInventory, wepaonSelectSlot.CurrentWeaponItemDataSO);
        }
        gameObject.SetActive(false);

        uI.EnableUIInput(false);
    }
}
